var t, e = (t = require("@vant/weapp/toast/toast")) && t.__esModule ? t : {
    default: t
};

var a = require("../../utils/config"), i = require("../../utils/request"), s = require("../../utils/api"), d = require("../../utils/encrypt"), o = require("../../utils/date");

Page({
    data: {
        themeColor: getApp().globalData.themeColor,
        noticeBar: {
            Color: "#ed6a0c",
            bgColor: "#fffbe8",
            text: "如无信息，请在下方用单位给的凭证认证添加。"
        },
        activeTab: 0,
        addCheckCardPopupShow: !1,
        cardNo: "",
        cardPassword: "",
        checkList: [],
        checkListN: [],
        checkListU: [],
        checkListZ: [],
        pageIndex: 1,
        pageSize: 10,
        title: "点击加载更多",
        btnConfirmLoading: !1
    },
    onShow: function() {
        this.getCardList(!0);
    },
    addCheckCard: function() {
        this.setData({
            addCheckCardPopupShow: !0
        });
    },
    onAddCheckCardPopupClose: function() {
        this.setData({
            addCheckCardPopupShow: !1
        });
    },
    confirm: function() {
        var t = this;
        "" != this.data.cardNo ? "" != this.data.cardPassword ? (this.setData({
            btnConfirmLoading: !0
        }), i.request(i.HttpMethod.POST, s.apiRoute.bindCheckCardByCardNoAndPassword, {
            cardNo: this.data.cardNo,
            passWord: this.data.cardPassword
        }).then(function(a) {
            "20000" == a.code ? (t.setData({
                btnConfirmLoading: !1
            }), (0, e.default)({
                message: "绑定成功",
                duration: 5e3
            }), wx.redirectTo({
                url: "/pages/my-link-check/my-link-check"
            }), wx.hideLoading()) : (t.setData({
                btnConfirmLoading: !1
            }), (0, e.default)({
                message: a.message,
                duration: 5e3
            }), wx.hideLoading());
        }).catch(function() {
            t.setData({
                btnConfirmLoading: !1
            }), wx.hideLoading();
        })) : (0, e.default)({
            message: "卡密不能为空",
            duration: 5e3
        }) : (0, e.default)({
            message: "卡号不能为空",
            duration: 5e3
        });
    },
    getCardList: function(t) {
        var c = this;
        wx.showLoading({
            title: "正在加载中...",
            mask: !0
        }), t && this.setData({
            pageIndex: 1,
            pageSize: 10,
            totalSize: 0,
            checkList: [],
            checkListN: [],
            checkListU: [],
            checkListZ: [],
            title: "点击加载更多"
        }), i.request(i.HttpMethod.POST, s.apiRoute.getCardListByJwtAndPage + "?pageSize=" + this.data.pageSize + "&pageIndex=" + this.data.pageIndex, {}).then(function(i) {
            if ("20000" == i.code) {
                var s = t ? [] : c.data.checkList, n = t ? [] : c.data.checkListN, r = t ? [] : c.data.checkListU, h = t ? [] : c.data.checkListZ;
                i.data.checkList.forEach(function(t) {
                    if (t.url = a.resourceRoot + "icon-card.png", t.mobileShow = d.encryptMobile(t.mobile), 
                    s.map(function(t) {
                        return t.checkCardNo;
                    }).indexOf(t.checkCardNo) <= -1) {
                        if (t.disableCheckButton = !0, "N" == t.status && n.push(t), "U" == t.status) o.formatDate(new Date(), "yyyy-MM-dd") == o.formatDate(new Date(t.resvDate), "yyyy-MM-dd") && (t.disableCheckButton = !1), 
                        r.push(t);
                        "Z" == t.status && h.push(t), s.push(t);
                    }
                }), wx.hideLoading(), (null == i.data.checkList || i.data.checkList.length <= 0) && (c.setData({
                    title: "我是有底线的"
                }), wx.showToast({
                    title: "已无更多数据",
                    duration: 3e3,
                    mask: !1,
                    icon: "none"
                })), c.setData({
                    checkList: s,
                    checkListN: n,
                    checkListU: r,
                    checkListZ: h
                });
            } else (0, e.default)({
                message: i.message,
                duration: 5e3
            }), wx.hideLoading();
        });
    },
    onShareAppMessage: function() {
        return {
            title: "瑞慈体检预约 - 报告查询",
            path: "/pages/my-link-check/my-link-check"
        };
    },
    addMore: function() {
        var t = this.data.pageIndex + 1;
        this.setData({
            pageIndex: t
        }), this.getCardList(!1);
    },
    onReload: function() {
        this.getCardList(!0);
    }
});